package com.ding.infra.feign.fallback;

import com.alibaba.fastjson2.JSONObject;
import com.ding.infra.feign.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @Author: ding
 * @Mail: dingpeng0831@hotmail.com
 * @CreateTime: 2023-03-27  17:00
 * @Description:
 * @Version: 1.0
 */
@Component
@Slf4j
public class StudentServiceFallBack implements StudentService {

    @Override
    public ResponseEntity<JSONObject> readData() {
        log.warn("{}:进入了降级方法......", Thread.currentThread().getName());
        return ResponseEntity
                .status(HttpStatus.BAD_GATEWAY)
                .body(new JSONObject().fluentPut("data", "not ok"));
    }
}
